<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function getTime(join) {
            const today = new Date();

            const year = today.getFullYear();  // 获取年份
            const month = String(today.getMonth() + 1).padStart(2, '0'); // 获取月份（0-11月）
            const date = String(today.getDate()).padStart(2, '0');  // 获取日

            const hours = String(today.getHours()).padStart(2, '0'); // 小时
            const minutes = String(today.getMinutes()).padStart(2, '0'); // 分
            const seconds = String(today.getSeconds()).padStart(2, '0'); // 秒

            if (join) {
                return `${year}${join}${month}${join}${date} ${hours}:${minutes}:${seconds}`
            }

            return `${year}年${month}月${date}日 ${hours}:${minutes}:${seconds}`
        }

        const date = getTime('-');

        console.log(date);


    </script>
</body>

</html>